package com.example.JavaWebApi.controller.systemController;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.JavaWebApi.core.apiinterceptors.annotation.Authorize;
import com.example.JavaWebApi.model.entity.systemEntity.Orginfo;
import com.example.JavaWebApi.service.systemService.IOrginfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *  前端控制器
 * @author 杨泽
 * @since 2022-06-15
 */
@RestController
@RequestMapping("/api/orginfo")
@Api(tags ="")
@Authorize
public class OrginfoController {
 
    @Autowired
    public IOrginfoService OrginfoService;

    @GetMapping("GetOrgTree")
    @ApiOperation("获取组织结构树")
    public List<Orginfo> getOrgList(){
        return OrginfoService.getOrgTree();
    }
    @GetMapping("GetLazyOrgList")
    @ApiOperation("获取组织机构信息")
    public IPage<Orginfo> getLazyOrgList(Integer parentId, int page, int limit){
        return OrginfoService.getLazyOrgList(parentId,page,limit);
    }
    @PostMapping("Create")
    @ApiOperation("创建一个组织机构节点")
    public Boolean create(@RequestBody Orginfo orginfo){
        return OrginfoService.create(orginfo);
    }
    @PostMapping("Update")
    @ApiOperation("更新组织机构节点")
    public boolean update(@RequestBody Orginfo orginfo){
        return OrginfoService.update(orginfo);
    }

    @GetMapping("Delete")
    @ApiOperation("删除组织结构节点")
    public boolean delete(Integer orgId){
        return OrginfoService.delete(orgId);
    }

}
